CMAKE_MINIMUM_REQUIRED(VERSION 3.10)

SET(CMAKE_SYSTEM_NAME Generic)
SET(CMAKE_SYSTEM_PROCESSOR cortex-m7)
#SET(CMAKE_VERBOSE_MAKEFILE ON)

SET(CMAKE_C_COMPILER "/Users/chenhonglin/Downloads/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-gcc")
SET(CMAKE_ASM_COMPILER "/Users/chenhonglin/Downloads/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-gcc")
SET(CMAKE_C_FLAGS " -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -Dgcc -O0 -gdwarf-2 -g -std=c99")
SET(CMAKE_ASM_FLAGS " -c -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -x assembler-with-cpp -Wa,-mimplicit-it=thumb  -gdwarf-2")
SET(CMAKE_C_COMPILER_WORKS TRUE)

SET(CMAKE_CXX_COMPILER "/Users/chenhonglin/Downloads/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-g++")
SET(CMAKE_CXX_FLAGS " -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -Dgcc -O0 -gdwarf-2 -g")
SET(CMAKE_CXX_COMPILER_WORKS TRUE)

SET(CMAKE_OBJCOPY "/Users/chenhonglin/Downloads/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-objcopy")
SET(CMAKE_SIZE "/Users/chenhonglin/Downloads/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-size")

SET(CMAKE_EXE_LINKER_FLAGS " -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,Reset_Handler -T ${CMAKE_SOURCE_DIR}/board/linker_scripts/link.lds")

SET(CMAKE_CXX_STANDARD 14)
PROJECT(rtthread C CXX ASM)
INCLUDE_DIRECTORIES(
	/Users/chenhonglin/dist/stm32h750-artpi-h750
	/Users/chenhonglin/dist/stm32h750-artpi-h750/board
	/Users/chenhonglin/dist/stm32h750-artpi-h750/board/CubeMX_Config/Core/Inc
	/Users/chenhonglin/dist/stm32h750-artpi-h750/board/port
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/HAL_Drivers
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/HAL_Drivers/config
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/STM32H7xx_HAL/CMSIS/Device/ST/STM32H7xx/Include
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/STM32H7xx_HAL/CMSIS/Include
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Inc
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/components/drivers/include
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/components/finsh
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/components/libc/compilers/common
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/components/libc/compilers/gcc/newlib
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/include
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/libcpu/arm/common
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/libcpu/arm/cortex-m7
)

ADD_DEFINITIONS(
	-DHAVE_CCONFIG_H
	-DRT_USING_NEWLIB
	-DSTM32H750xx
	-DUSE_HAL_DRIVER
	-D__RTTHREAD__
)

SET(PROJECT_SOURCES
	/Users/chenhonglin/dist/stm32h750-artpi-h750/applications/main.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/libcpu/arm/common/div0.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/libcpu/arm/common/showmem.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/libcpu/arm/common/backtrace.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/libcpu/arm/cortex-m7/cpuport.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/libcpu/arm/cortex-m7/cpu_cache.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/libcpu/arm/cortex-m7/context_gcc.S
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/components/drivers/misc/pin.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/components/drivers/serial/serial.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/components/drivers/src/pipe.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/components/drivers/src/ringblk_buf.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/components/drivers/src/waitqueue.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/components/drivers/src/workqueue.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/components/drivers/src/ringbuffer.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/components/drivers/src/dataqueue.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/components/drivers/src/completion.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/board/board.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/board/CubeMX_Config/Core/Src/stm32h7xx_hal_msp.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/STM32H7xx_HAL/CMSIS/Device/ST/STM32H7xx/Source/Templates/gcc/startup_stm32h750xx.s
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/HAL_Drivers/drv_common.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/HAL_Drivers/drv_gpio.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/HAL_Drivers/drv_usart.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/components/finsh/msh.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/components/finsh/cmd.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/components/finsh/shell.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/src/mem.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/src/scheduler.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/src/mempool.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/src/timer.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/src/idle.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/src/components.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/src/kservice.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/src/clock.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/src/object.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/src/thread.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/src/irq.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/src/ipc.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/src/device.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/components/libc/compilers/gcc/newlib/syscalls.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/rt-thread/components/libc/compilers/common/time.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_sram.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dma.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pwr_ex.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_usart.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_cryp_ex.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rng.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dma_ex.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_crc.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rcc.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_cryp.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_crc_ex.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_uart_ex.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_mdma.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/STM32H7xx_HAL/CMSIS/Device/ST/STM32H7xx/Source/Templates/system_stm32h7xx.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rcc_ex.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_cortex.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_gpio.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_comp.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_cec.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_uart.c
	/Users/chenhonglin/dist/stm32h750-artpi-h750/libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pwr.c
)

LINK_DIRECTORIES(
)

LINK_LIBRARIES(
	m
)

ADD_EXECUTABLE(${CMAKE_PROJECT_NAME}.elf ${PROJECT_SOURCES})
ADD_CUSTOM_COMMAND(TARGET ${CMAKE_PROJECT_NAME}.elf POST_BUILD 
COMMAND ${CMAKE_OBJCOPY} -O binary ${CMAKE_PROJECT_NAME}.elf ${CMAKE_PROJECT_NAME}.bin COMMAND ${CMAKE_SIZE} ${CMAKE_PROJECT_NAME}.elf)